[This is a user-defined function you need to create]
You may define a change indication function which will be called whenever a
difference during the comparison run has been found. Parameters supplied include old and new value as well as location in the new table
(column name and row number). The return value will placed into the report table.
The function allows further flexibility, e.g. reporting changes differently under different columns differently
(e.g. column "delivery date" could be reported as "same", "earlier", "later").
Depending on the last parameter in table compare(), this function can either be called for every value pair compared, or
just for value pairs which are different.
You need to create a user-defined function complying with the parameter structure described below and must return a value of any type.
The returned value will be converted to strings automatically after the function calls.
"Synopsis": "define function( my function, {{ old value, string }, {new value, string}, {header name, string}, {row number, numeral}} ) { [statements} }"
Indirect parameter passing is disabled
4
No. | Type | Description |
---|---|---|
1. input |
string | Old value Value from the older table |
2. input |
string | New value Value from the newer table |
3. input |
string | Header name Name of header referring to the table column of the values |
4. input |
string | Row number Name of header referring to the table column of the values |
Type | Description |
---|---|
valid types | Change remark Return the value or text you want to see in the comparison report if the values are different (or equal). |
define function( foo, {{ old value, string }, {new value, string}, {header name, string}, {row number, numeral}} )
{
if (num(new value[])<>0)
{
return( select if ( new value[] > old value[], "Older", "Younger" ) );
}
return( old value[] + " --> " + new value[] );
}
table initialize( t1,
{ { Name, Age, Town },
{ Ann, 35, Boston }, { Bea, 45, Cambridge },
{ Beat, 46, Chicago }, { Chuck,55, New Heaven },
{ Emil, 21, Albany }} );
table initialize( t2,
{ { Name, Age, Town },
{ Ann, 34, Boston }, { Bea, 46, Cambridge },
{ Beat, 46, Chicago }, { Chuck,55, New Haven },
{ Dale, 65, Newport }} );
table compare ( t2, t1, report, Name, differences, foo, true );
table delete columns( report, {Statistics Parameters, Statistics Values} ); // Ignore for now
table delete blank rows( report );
echo("Comparison Report:");
table list ( report );
Comparison Report:
0 : Name | Age | Town | Change Remarks
1 : Ann | Younger | | Data modified
2 : Bea | Older | | Data modified
3 : Beat | | | Data unchanged
4 : Chuck | | New Heaven --> New Haven | Data modified
5 : Dale | Older | --> Newport | Row added
6 : Emil | 21 --> | Albany --> | Row deleted